import {
  IFormProps,
  size,
  formItemLayout,
  newFormItemLayout,
  getUploadResult,
  productPage,
  getImages,
  getFileList
} from "../../utils/common";
import React from "react";
import {
  Modal,
  Form,
  Input,
  Select,
  Upload,
  Checkbox,
  InputNumber
} from "antd";
import * as api from "../../api/api";
import { FormComponentProps } from "antd/lib/form";
import Uploads from "../Uploads";
const TextArea = Input.TextArea;
export interface IReleasePointRuleEditProps extends FormComponentProps {
  visible: boolean;
  releasePointRule?: api.SingleUserMallMallVOReleasePointRulesVO;
  onSave: (any) => void;
  onCancel: () => void;
}
class ReleasePointRuleEdit extends React.PureComponent<
  IReleasePointRuleEditProps,
  any
> {
  constructor(props) {
    super(props);
  }

  state = {};

  componentDidMount() {}

  ok = e => {
    e.preventDefault();
    this.props.form.validateFieldsAndScroll((err, form) => {
      if (!err) {
        this.props.onSave(form);
      }
    });
  };

  cancel = () => {
    this.props.onCancel();
  };

  levelChange = value => {
    this.setState({ userRuleLevel: value });
  };

  render(): JSX.Element {
    const { getFieldDecorator } = this.props.form;
    const { releasePointRule } = this.props;
    return (
      <Modal
        title="体验金释放规则"
        visible={this.props.visible}
        onOk={this.ok}
        onCancel={this.cancel}
        maskClosable={true}
      >
        <Form>
          <Form.Item label="名称" {...newFormItemLayout}>
            {getFieldDecorator("name", {
              rules: [
                {
                  required: true,
                  message: "请填写名称"
                }
              ],
              initialValue: releasePointRule && releasePointRule.name
            })(<Input placeholder="名称" />)}
          </Form.Item>
          <Form.Item label="普通用户自购返还比例" {...newFormItemLayout}>
            {getFieldDecorator("normalUserOwnBuyRate", {
              initialValue: releasePointRule && releasePointRule.normalUserOwnBuyRate
            })(<InputNumber placeholder="请输入比例" min={0} max={1} />)}
          </Form.Item>
          <Form.Item label="VIP用户自购返还比例" {...newFormItemLayout}>
            {getFieldDecorator("vipUserOwnBuyRate", {
              initialValue: releasePointRule && releasePointRule.vipUserOwnBuyRate
            })(<InputNumber placeholder="请输入比例" min={0} max={1} />)}
          </Form.Item>
          <Form.Item label="合伙人自购返还比例" {...newFormItemLayout}>
            {getFieldDecorator("superVIPUserOwnBuyRate", {
              initialValue: releasePointRule && releasePointRule.superVIPUserOwnBuyRate
            })(<InputNumber placeholder="请输入比例" min={0} max={1} />)}
          </Form.Item>
          <Form.Item label="直推普通用户返还VIP比例" {...newFormItemLayout}>
            {getFieldDecorator("directNormalUserToVIPRate", {
              initialValue: releasePointRule && releasePointRule.directNormalUserToVIPRate
            })(<InputNumber placeholder="请输入比例" min={0} max={1} />)}
          </Form.Item>
          <Form.Item label="直推普通用户返还合伙人比例" {...newFormItemLayout}>
            {getFieldDecorator("directNormalUserToSuperVIPRate", {
              initialValue: releasePointRule && releasePointRule.directNormalUserToSuperVIPRate
            })(<InputNumber placeholder="请输入比例" min={0} max={1} />)}
          </Form.Item>
          <Form.Item label="VIP团队返还合伙人比例" {...newFormItemLayout}>
            {getFieldDecorator("directVIPGroupUserToSuperVIPRate", {
              initialValue: releasePointRule && releasePointRule.directVIPGroupUserToSuperVIPRate
            })(<InputNumber placeholder="请输入比例" min={0} max={1} />)}
          </Form.Item>
          <Form.Item label="直推合伙人返还合伙人比例" {...newFormItemLayout}>
            {getFieldDecorator("directSuperVIPUserToSuperVIPRate", {
              initialValue: releasePointRule && releasePointRule.directSuperVIPUserToSuperVIPRate
            })(<InputNumber placeholder="请输入比例" min={0} max={1} />)}
          </Form.Item>
          <Form.Item label="直推合伙人返还VIP比例" {...newFormItemLayout}>
            {getFieldDecorator("directSuperVIPUserToVIPRate", {
              initialValue: releasePointRule && releasePointRule.directSuperVIPUserToVIPRate
            })(<InputNumber placeholder="请输入比例" min={0} max={1} />)}
          </Form.Item>
          <Form.Item label="直推合伙人返还普通用户比例" {...newFormItemLayout}>
            {getFieldDecorator("directSuperVIPUserToNormalUserRate", {
              initialValue: releasePointRule && releasePointRule.directSuperVIPUserToNormalUserRate
            })(<InputNumber placeholder="请输入比例" min={0} max={1} />)}
          </Form.Item>
        </Form>
      </Modal>
    );
  }
}

export default Form.create()(ReleasePointRuleEdit);
